// 接口方法, 只负责调用一个接口, 返回一个Promise对象
import ajax from '@/utils/request'
// 需要导入store才可以请求到token
// import store from '@/store'
// 请求频道列表
const getUserChannelListAPI = () => {
  // 携带data
  return ajax({
    method: 'GET',
    url: '/v1_0/user/channels'

  })
}
// 请求文章列表
const getArticlesListAPI = ({ channelId, timestamp = Date.now() }) => {
  // 携带data
  return ajax({
    method: 'GET',
    url: '/v1_0/articles',
    params: {
      channel_id: channelId,
      timestamp
    }
  })
}
// 文章_不感兴趣
const articleDislikeAPI = ({ artid }) => {
  return ajax({
    url: '/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: artid
    }

  })
}
// 文章_举报
const articleReportAPI = ({ artid, type, remark }) => {
  return ajax({
    url: '/v1_0/article/reports',
    method: 'POST',
    data: {
      target: artid,
      type,
      remark
    }

  })
}
// 获取所有的频道列表
const getAllChannelsListAPI = () => {
  return ajax({
    url: '/v1_0/channels',
    method: 'GET'

  })
}
// 更新用户频道列表
const updateUserchannelListAPI = ({ channels }) => {
  return ajax({
    url: '/v1_0/user/channels',
    method: 'PUT',
    data: {
      channels
    }
  })
}
export {
  getUserChannelListAPI, getArticlesListAPI, articleDislikeAPI, articleReportAPI, getAllChannelsListAPI,
  updateUserchannelListAPI
}
